package leetcode.code2022;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public int[][] construct2DArray(int[] original, int m, int n) {
		int len = original.length;
		if (len != m * n) {
			return new int[][] {};
		}
		int[][] ans = new int[m][n];
		int row = 0;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				ans[i][j] = original[row * n + j];
			}
			row++;
		}
		return ans;
	}

	@Override
	public void debug1() {
		int[][] e = HelpDebug.str2array1("[[1,2],[3,4]]");
		HelpDebug.compare(e, this.construct2DArray(HelpDebug.str2array3("[1,2,3,4]"), 2, 2));

	}

	@Override
	public void debug2() {
		int[][] e = HelpDebug.str2array1("[]");
		HelpDebug.compare(e, this.construct2DArray(HelpDebug.str2array3("[1,2]"), 1, 1));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
//		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
	}

}
